/*
 * Copyright (C) 2010-2101 Alibaba Group Holding Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.alibaba.otter.manager.biz.statistics.delay.param;

import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @author jianghang 2013-3-12 下午06:12:38
 * @version 4.1.7
 */
@Setter
@Getter
public class TopDelayStat {

    private String channelName;
    private String pipelineName;
    private Long channelId;
    private Long pipelineId;
    private Long delayTime;
    private Date lastUpdate;                     // 延迟统计最后一次更新时间
    private Long statTime;                       // stat统计时间范围,分钟为单位
    private DataStat dbStat = new DataStat(0L, 0L);
    private DataStat fileStat = new DataStat(0L, 0L);

    /**
     * 获取延迟统计最后更新时间距当前时间的差值
     */
    public Long getLastUpdateDelay() {
        return (new Date().getTime() - lastUpdate.getTime()) / 1000;
    }

    @Setter
    @Getter
    public static class DataStat {

        public DataStat(Long number, Long size) {
            this.number = number;
            this.size = size;
        }

        private Long number;
        private Long size;

    }
}
